import table from '@/components/dt/table/render.js'
import Opt from '@/components/dt/info/Opt.js'
import dt from '@dt/dt'

let _this = null

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      {
        title: '序号',
        type: 'index',
        width: 80,
        align: 'center'
      },
      {
        title: '申请月份',
        field: 'applyMonth',
        minWidth: 150,
        align: 'center'
      },
      {
        title: '延期原因',
        field: 'extendReason',
        minWidth: 150,
        align: 'center',
        slots: {
          default: (params, h) => {
            return dt.dictInfo().__value('bonusExtendReason', params.row.extendReason)
          }
        }
      },
      {
        title: '提交人',
        field: 'createUserName',
        minWidth: 150,
        align: 'center'
      },
      {
        title: '提交时间',
        field: 'createTime',
        minWidth: 180,
        align: 'center'
      },
      {
        title: '状态',
        field: 'status',
        minWidth: 120,
        align: 'center',
        slots: {
          default: (params, h) => {
            return dt.dictInfo().__value('bonusExtendStatus', params.row.status)
          }
        }
      },
      {
        title: '处理人',
        field: 'updateUserName',
        minWidth: 120,
        align: 'center'
      },
      {
        title: '处理时间',
        field: 'updateTime',
        minWidth: 180,
        align: 'center'
      },
      {
        title: '操作',
        minWidth: 180,
        align: 'center',
        fixed: 'right',
        slots: {
          default: (params, h) => {
            let btns = [
              {
                title: '查看',
                event: 'checkFun',
                data: params.row
              },
              {
                title: params.row.status == 'APPROVAL' ? '撤回' : '',
                event: 'revocation',
                data: params.row
              },
              {
                title: params.row.status == 'WITHDRAWN' ? '删除' : '',
                event: 'delFun',
                data: params.row
              }
            ]
            return table.cell.btns(_this, h, btns)
          }
        }
      }
    ]
  }
}

export default Column
